﻿@model string
@{
    string m = Model;
    DateTime dt = Now;
    if (DateTime.TryParse(m, out dt))
    {
        if (dt == DateTime.MinValue) { dt = Now; }
        if (dt.Hour == 0 && dt.Minute == 0 && dt.Second == 0) { m = dt.ToString("yyyy-MM-dd"); }
        else { m = dt.ToString("yyyy-MM-dd HH:ss"); }
    }
}
@{var g = "D" + Guid.NewGuid().ToString("N");}
<span class="small-input">
    @Html.TextBox("", m, new { id = g })
    <script type="text/javascript">        $(function () { $('#@(g)').datepicker(); });</script>
</span>